package hust.ioic.oa.service.impl;


import java.util.List;

import hust.ioic.oa.base.BaseDaoImpl;
import hust.ioic.oa.domain.Rdfile;
import hust.ioic.oa.service.RdfileService;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
@SuppressWarnings("unchecked")
public class RdfileServiceImpl extends BaseDaoImpl<Rdfile> implements RdfileService {

	@Override
	public Rdfile getByTextId(Integer textId) {
		// TODO Auto-generated method stub
		return (Rdfile)getSession().createQuery("FROM Rdfile r WHERE r.textId=?")
				.setParameter(0,textId)//
				.uniqueResult();
	}

	@Override
	public Rdfile getByName(String name) {
		return (Rdfile)getSession().createQuery("FROM Rdfile r WHERE r.name=?")
				.setParameter(0,name)//
				.uniqueResult();
	}
	
	@Override
	public Rdfile getById(Integer id) {
		return (Rdfile)getSession().createQuery("FROM Rdfile r WHERE r.id=?")
				.setParameter(0,id)//
				.uniqueResult();
	}

	@Override
	public List<Rdfile> getFilesByOperator(Integer id) {
		return getSession().createQuery("FROM  Rdfile r WHERE r.operatorId =?")
				.setParameter(0, id)
				.list();
	}



}
